<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('渠道失败订单')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li class="select-time">
                                <label>下单时间：</label>
                                <input type="text" class="time-input" data-type="datetime" style="width: 150px;" id="startTime" placeholder="开始时间" name="params[beginStoreOrderTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" data-type="datetime" style="width: 150px;" id="endTime" placeholder="结束时间" name="params[endStoreOrderTime]"/>
                            </li>
                            <li class="select-time">
                                <label>完成时间：</label>
                                <input type="text" class="time-input" data-type="datetime" style="width: 150px;" id="startTime" placeholder="开始时间" name="params[beginOrderFinishTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" data-type="datetime" style="width: 150px;" id="endTime" placeholder="结束时间" name="params[endOrderFinishTime]"/>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="sysOrderStatus" th:with="type=${@dict.getType('sys_order_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>处理状态：</label>
                                <select name="manuaDoStatus" th:with="type=${@dict.getType('manua_do_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 80px;">系统订单号：</label>
                                <input type="text" name="sysOrderNo"/>
                            </li>
                            <li>
                                <label style="width: 80px;">商家订单号：</label>
                                <input type="text" name="storeOrderNo"/>
                            </li>

                            <li>
                                <label style="width: 80px;">渠道订单号：</label>
                                <input type="text" name="channelOrderNo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <!--<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="system:ordererror:export">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.batchRepair()" shiro:hasPermission="system:ordererror:batchRepair">
                    <i class="fa fa-plus"></i> 批量补单
                </a>
                <a class="btn btn-success" onclick="$.operate.batchCancel()" shiro:hasPermission="system:ordererror:batchCancel">
                    <i class="fa fa-plus"></i> 批量撤单
                </a>

                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ordererror:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:ordererror:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:ordererror:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ordererror:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:ordererror:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:ordererror:remove')}]];
        var realRechargePlatDatas = [[${@dict.getType('real_recharge_plat')}]];
        var sysOrderStatusDatas = [[${@dict.getType('sys_order_status')}]];
        var manuaDoStatusDatas = [[${@dict.getType('manua_do_status')}]];
        var cancelOrderStatusDatas = [[${@dict.getType('cancel_order_status')}]];
        var repairOrderStatusDatas = [[${@dict.getType('repair_order_status')}]];
        var prefix = ctx + "system/ordererror";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                batchRepairUrl: prefix + "/batchRepair",
                batchCancelUrl: prefix + "/batchCancel",
                repairUrl: prefix + "/repair",
                repairRedoUrl: prefix + "/repairRedo",
                cancelUrl: prefix + "/cancel",
                cancelRedoUrl: prefix + "/cancelRedo",
                modalName: "订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'sysOrderNo',
                    title: '系统订单号'
                },
                {
                    field: 'storeOrderNo',
                    title: '商家订单号'
                },
                {
                    field: 'channelOrderNo',
                    title: '渠道订单号',
                    visible: false
                },
                {
                    field: 'storeName',
                    title: '商户名称'
                },
                {
                    field: 'storeCode',
                    title: '商户编号'
                },
                {
                    field: 'channelCode',
                    title: '渠道编号'
                },
                {
                    field: 'channelName',
                    title: '渠道名称'
                },
                {
                    field: 'userMobile',
                    title: '充值号码'
                },
                {
                    field: 'userAmount',
                    title: '充值金额'
                },
                {
                    field: 'operator',
                    title: '运营商'
                },
                {
                    field: 'storeOrderTime',
                    title: '商家下单时间',
                    formatter: function(value, row, index) {
                        return $.common.dateFormat(row.storeOrderTime,"yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    field: 'channelErrorTime',
                    title: '渠道失败回执时间',
                    formatter: function(value, row, index) {
                        return $.common.dateFormat(row.channelErrorTime,"yyyy-MM-dd HH:mm:ss");
                    }
                },
                {
                    field: 'sysOrderStatus',
                    title: '订单状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sysOrderStatusDatas, value);
                    }
                },
                {
                    field: 'manuaDoStatus',
                    title: '处理状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(manuaDoStatusDatas, value);
                    }
                },
                {
                    field: 'cancelOrderStatus',
                    title: '撤单操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //manuaDoStatus     人工处理状态 1=待处理 2=已处理
                        //cancelOrderStatus 撤单状态 1=已撤单 2=未撤单
                        //repairOrderStatus 补单状态 1=已补单 2=未补单
                        if(row.manuaDoStatus==1 && row.cancelOrderStatus==2){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa"></i>撤单</a> ');
                        }else if(row.manuaDoStatus==2 && row.repairOrderStatus==1){
                            actions.push('撤单');
                        }else if(row.manuaDoStatus==2 && row.cancelOrderStatus==1){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.cancelRedo(\'' + row.id + '\')"><i class="fa"></i>取消撤单</a>');
                        }

                        /*if(row.cancelOrderStatus==1){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.cancelRedo(\'' + row.id + '\')"><i class="fa"></i>取消撤单</a>');
                        }else{
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa"></i>撤单</a> ');
                        }*/
                        return actions.join('');
                    }
                },
                {
                    field: 'repairOrderStatus',
                    title: '补单操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        //manuaDoStatus     人工处理状态 1=待处理 2=已处理
                        //cancelOrderStatus 撤单状态 1=已撤单 2=未撤单
                        //repairOrderStatus 补单状态 1=已补单 2=未补单
                        if(row.manuaDoStatus==1 && row.repairOrderStatus==2){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.repair(\'' + row.id + '\')"><i class="fa"></i>补单</a> ');
                        }else if(row.manuaDoStatus==2 && row.cancelOrderStatus==1){
                            actions.push('补单');
                        }else if(row.manuaDoStatus==2 && row.repairOrderStatus==1){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.repairRedo(\'' + row.id + '\')"><i class="fa"></i>取消补单</a>');
                        }

                        /*if(row.repairOrderStatus==1){
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.repairRedo(\'' + row.id + '\')"><i class="fa"></i>取消补单</a>');
                        }else{
                            actions.push('<a class="btn btn-xs" href="javascript:void(0)" onclick="$.operate.repair(\'' + row.id + '\')"><i class="fa"></i>补单</a> ');
                        }*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });



    </script>
</body>
</html>